﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using System.ServiceModel.Description;
using System.ServiceModel.Web;

namespace DuplexDeviceEvent
{
    #region Host Implementation

    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Starting WCF Host for DuplexDeviceEvent...");
            string baseAddress = "http://localhost:8000";
            DeviceEventRunner runner = new DeviceEventRunner();

            using (ServiceHost host = new ServiceHost(typeof(DeviceEventService), new Uri(baseAddress)))
            {
                host.AddServiceEndpoint(typeof(IPolicyRetriever), new WebHttpBinding(), "").Behaviors.Add(new WebHttpBehavior());
                host.AddServiceEndpoint(typeof(IDeviceEventService), new PollingDuplexHttpBinding(), "DeviceEventService");

                ServiceMetadataBehavior smb = new ServiceMetadataBehavior();
                smb.HttpGetEnabled = true;
                smb.MetadataExporter.PolicyVersion = PolicyVersion.Policy15;
                host.Description.Behaviors.Add(smb);
                host.Open();

                Console.WriteLine("WCF Host Running...");
                Console.WriteLine("Press <ENTER> to shutdown");
                Console.ReadLine();

                host.Close();
            }
        }
    }
    #endregion
}
